<?php

class m_rights_actions_block_ListRightsAction extends m_backoffice_extends_Action
{
    private $group;

	public function execute()
	{
		$subTabName = $this->getRequestParameter("subTabName", "website");
        $accordionTabName = $this->getRequestParameter("accordionTabName");
        $this->group = $this->getDocumentProvider()->getByUniqueId($this->getRequestParameter("docId"));

        $view = $this->getDocList($subTabName, $accordionTabName);

        $this->addToModel('accordionTabName',$accordionTabName);
        $this->addToModel('subTabName',$subTabName);
        $this->addToModel('group',$this->group);

        $this->setView($view);
	}	
	
	public function validate()
	{
		return $this->getUserContext()->hasRight(array("backoffice_accessBo","rights_Show"));
	}

    private function getDocList($subTabName, $accordionTabName = null)
    {
        $docList = '<ul id="docList" class="filetree treeview"></ul>';
        $this->addToModel('docList', $docList);

        if($subTabName == "modules")
        {
            if(!is_null($accordionTabName))
            {
                return 'ajax';
            }
            else
            {
                $modules = m_backoffice_services_ModulesService::getInstance()->getModulesList();
                $this->addToModel("modules", $modules);
            }
        }

        return 'success';
    }
}